using System.Threading;
using Legend.Threading;
using NUnit.Framework;

namespace Legend.Core.Tests.Threading.ThreadingExtensionsTests
{
    public abstract class ISynchronizationManagerFactoryContractTests
    {
        private ISynchronizationManagerFactory factory;

        [SetUp]
        public void SetUp()
        {
            this.OnSetUp();
        }

        protected virtual void OnSetUp()
        {
            this.factory = this.CreateFactory();
        }

        protected abstract ISynchronizationManagerFactory CreateFactory();

        [Test]
        public void CreateSynchronizationManager_should_return_manager_that_supports_recursion_when_SupportsRecursion_is_specified()
        {
            // Arrange

            // Act
            var result = this.factory.CreateSynchronizationManager(LockRecursionPolicy.SupportsRecursion);

            // Assert
            Assert.That(result.RecursionPolicy, Is.EqualTo(LockRecursionPolicy.SupportsRecursion));
        }
    }
}
